{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Introduction to Operating System \n",
    "\n",
    "An operating system falls under the category of system software that performs all the fundamental tasks like file management, memory handling, process management, handling the input/output, and governing and managing the peripheral devices like disk drives, networking hardware, printers, etc.\n",
    "\n",
    "操作系统是计算机系统中直接控制和管理各种软硬件资源，以方便用户充分而有效地利用这些资源的程序的集合\n",
    "\n",
    "* Memory Management 内存管理\n",
    "* Processor Managing 处理器管理\n",
    "* Device Managing 设备管理\n",
    "* File Managing文件管理、\n",
    "* interface connecting a user with the computer.用户接口\n",
    ">操作系统主要五大功能：处理机管理，存储器管理，设备管理，文件管理，操作系统与用户之间的接口\n",
    "\n",
    "Some well-liked Operating Systems are Linux, Windows, OS X, Solaris, OS/400, Chrome OS, etc.\n",
    "\n",
    "\n",
    "## Objectives of operating system \n",
    "\n",
    "An operating system consists of a special program that controls the execution of the application program. The OS acts as an intermediary between applications and hardware components. OS can be thought of as having three objectives. These are:\n",
    "\n",
    "* **Convenience**: It makes a computer more suitable to use.\n",
    "* **Efficiency**: It provides the computer system resources with efficiency and in easy to use format.\n",
    "* **Ability to develop**: It should be built in such a way that it permits the efficient development, testing, and installation of new system functions without interfering with service.\n",
    "\n",
    "## The History\n",
    "\n",
    "The first digital computers had no operating systems. They ran one program at a time, which had command of all system resources, and a human operator would provide any special resources needed. \n",
    "\n",
    "The first operating systems were developed in the mid-1950s. These were small “supervisor programs” that provided basic I/O operations (such as controlling punch card readers and printers) and kept accounts of CPU usage for billing. \n",
    "\n",
    "Supervisor programs also provided **multi-programming（多道程序）** capabilities to enable several programs to run at once. This was particularly important so that these early multimillion-dollar machines would not be idle during slow I/O operations.\n",
    "\n",
    "Computers acquired more powerful operating systems in the 1960s with the emergence of **time-sharing（分时）**, which required a system to manage multiple users sharing CPU time and terminals.\n",
    "\n",
    "Two early time-sharing systems were CTSS (Compatible Time Sharing System), developed at the Massachusetts Institute of Technology, and the Dartmouth College Basic System, developed at Dartmouth College. Other multiprogrammed systems included Atlas, at the University of Manchester, England, and IBM’s OS/360, probably the most complex software package of the 1960s. \n",
    "\n",
    "After 1972 the Multics system for General Electric Co.’s GE 645 computer (and later for Honeywell Inc.’s computers) became the most sophisticated system, with most of the **multiprogramming** and **time-sharing** capabilities that later became standard.\n",
    "\n",
    "The minicomputers of the 1970s had limited memory and required smaller operating systems. The most important operating system of that period was **UNIX**, developed by AT&T for large minicomputers as a simpler alternative to Multics. It became widely used in the 1980s, in part because it was **free** to universities and in part because it was designed with a set of tools that were powerful in the hands of skilled programmers.\n",
    "\n",
    "More recently, **Linux**, an open-source version of UNIX developed in part by a group led by Finnish computer science student `Linus Torvalds` and in part by a group led by American computer programmer `Richard Stallman`, has become popular on personal computers as well as on larger computers.\n",
    "\n",
    "In addition to such general-purpose systems, special-purpose operating systems run on small computers that control assembly lines, aircraft, and even home appliances. They are *real-time** systems, designed to provide rapid response to sensors and to use their inputs to control machinery. \n",
    "\n",
    "Operating systems have also been developed for mobile devices such as smartphones and tablets. Apple Inc.’s iOS, which runs on iPhones and iPads, and Google Inc.’s Android are two prominent **mobile operating systems**.\n",
    "\n",
    "## Different types of operating system\n",
    "\n",
    "There are different types of operating system those are organized by their Working.\n",
    "\n",
    "###  Batch Processing(批处理系统) :\n",
    "\n",
    "Batch Operating System: the First operating system of the second-generation computer is the batch operating system.\n",
    "\n",
    "Batch operating system took the input on the punch card. Each punch card had the different form of data. System executed the jobs one by one in batch. When one job from the batch executed, then the second job has taken from it and so on. The process of placing the jobs in queue for execution is known as spooling.\n",
    "\n",
    "**How its work:**\n",
    "\n",
    " OS keeps the number of jobs in memory and executes them one by one. Jobs processed in first come first served order. Each `set of a job considered as a batch`.\n",
    " \n",
    " When a job completes its execution, its memory is released, and the output for the job gets copied into an output spool for later printing or processing. \n",
    " \n",
    " User interaction in the batch processing system is minimal. One’s system accepts the jobs from users, and then the user is free. \n",
    " \n",
    " That is why we can use batch processing system in large organizations in these days.\n",
    "\n",
    "The batch processing system used where we want to update the data related to any transactions or any record. Transactions can be related to any customer orders, receipts, invoices, payments, online transactions, data entry, payroll system, banks etc.\n",
    "\n",
    "### Multi-Programming(多道系统)\n",
    "\n",
    "In Multi programming Operating System Multiple Programs are Executed on the System at a Time.\n",
    "\n",
    "In multi-programming system, when one program is `waiting for I/O transfer`; there is another program ready to utilize the CPU. So it is possible for several jobs to share the time of the CPU. \n",
    "\n",
    "But it is important to note that multi-programming is not defined to be the execution of jobs at the same instance of time. Rather it does mean that there are a number of jobs available to the CPU (placed in main memory) and a portion of one is executed then a segment of another and so on.\n",
    "\n",
    "A simple process of multi-programming is shown in figure\n",
    "\n",
    "![Multi-Programming](./img/linux/Operation-of-Multiprogramming-System.jpg)\n",
    "\n",
    "As shown in fig, at the particular situation,\n",
    "\n",
    "*  job `A` is not utilizing the CPU time because it is busy in I/ 0 operations. Hence the CPU becomes busy to execute the job `B`. Another job `C` is waiting for the CPU for getting its execution time. So in this state the CPU will never be idle and utilizes maximum of its time.\n",
    "\n",
    "A program in execution is called a  `Process`, `Job` or a `Task`. The concurrent execution of programs improves the utilization of system resources and enhances the system throughput as compared to batch and serial processing. In this system, when a process requests some I/O to allocate; meanwhile the CPU time is assigned to another ready process. So, here when a process is switched to an I/O operation, the CPU is not set idle.\n",
    "\n",
    "Multi-programming is a common approach to resource management. The essential components of a single-user operating system include a command processor, an input/ output control system, a file system, and a transient area. A multi-programming operating system builds on this base, subdividing the transient area to hold several independent programs and adding resource management routines to the operating system’s basic functions.\n",
    "\n",
    "  * Multi-programming Batch System(多道批处理系统)  \n",
    "\n",
    "### Time-sharing(分时):\n",
    "\n",
    "A time sharing system allows many users to share the computer resources simultaneously. In other words, `time sharing refers to the allocation of computer resources in time slots to several programs simultaneously`. \n",
    "\n",
    "For example: a mainframe computer that has many users logged on to it. Each user uses the resources of the mainframe -i.e. memory, CPU etc. The users feel that they are exclusive user of the CPU, even though this is not possible with one CPU i.e. shared among different users.\n",
    "\n",
    "The time sharing systems were developed to provide an interactive use of the computer system. A time shared system uses CPU scheduling and multi-programming to provide each user with a small portion of a time-shared computer. It allows many users to share the computer resources simultaneously. As the system switches rapidly from one user to the other, a short time slot is given to each user for their executions.\n",
    "\n",
    "The time sharing system provides the direct access to a large number of users where CPU time is divided among all the users on scheduled basis. The OS allocates a set of time to each user. When this time is expired, it passes control to the next user on the system. The time allowed is extremely small and the users are given the impression that they each have their own CPU and they are the sole owner of the CPU. This short period of time during that a user gets attention of the CPU; is known as a time slice or a quantum. \n",
    "\n",
    "The concept of time sharing system is shown in figure.\n",
    "\n",
    "![Time-sharing](./img/linux/Time-Sharing-System-Active-State-of-User.jpg)\n",
    "\n",
    "In above figure :\n",
    "\n",
    "the user `5` is active , but user 1, user 2, user 3, and user 4 are in waiting state whereas user 6 is in ready status.\n",
    "\n",
    "As soon as the time slice of user 5 is completed, the control moves on to the next ready user i.e. user 6. In this state user 2, user 3, user 4, and user 5 are in waiting state and user 1 is in ready state. The process continues in the same way and so on.\n",
    "\n",
    "The time-shared systems are more complex than the multi-programming systems. In time-shared systems multiple processes are managed simultaneously which requires an adequate management of main memory so that the processes can be swapped in or swapped out within a short time.\n",
    "\n",
    "### Multiprocessor(多处理器):\n",
    "\n",
    "* Multiprocessor(多处理器): In This type of operating system there are two or More CPU in a Single OS.\n",
    "\n",
    "Multiprocessor Operating System refers to the use of two or more central processing units (CPU) within a single computer system. These multiple CPUs are in a close communication sharing the computer bus, memory and other peripheral devices. These systems are referred as tightly coupled systems.\n",
    "\n",
    "These types of systems are used when very high speed is required to process a large volume of data. These systems are generally used in environment like satellite control, weather forecasting etc.\n",
    "\n",
    "The basic organization of multiprocessing system is shown in fig.\n",
    "\n",
    "![Multiprocessing-System](./img/linux/Multiprocessing-System.jpg)\n",
    "\n",
    "Multiprocessing system is based on the symmetric multiprocessing model, in which each processor runs an identical copy of operating system and these copies communicate with each other. In this system processor is assigned a specific task. A master processor controls the system. This scheme defines a master-slave relationship. These systems can save money in compare to single processor systems because the processors can share peripherals, power supplies and other devices. The main advantage of multiprocessor system is to get more work done in a shorter period of time. Moreover, multiprocessor systems prove more reliable in the situations of failure of one processor. In this situation, the system with multiprocessor will not halt the system; it will only slow it down.\n",
    "\n",
    "###  Real Time System(实时)\n",
    "\n",
    "* Time System are used there Requires higher and Timely Response.\n",
    "\n",
    "The real-time operating system used for a real-time application means for those applications where data processing should be done in the `fixed and small quantum of time`.\n",
    "\n",
    "It is different from general purpose computer where time concept is not considered as much crucial as in Real-Time Operating System. \n",
    " \n",
    "RTOS is a time-sharing system based on clock interrupts. Interrupt Service Routine (ISR) serve the interrupt, raised by the system. RTOS used Priority to execute the process. When a high priority process enters in system low priority process preempted to serve higher priority process. Real-time operating system synchronized the process. So that they can communicate with each other. Resources can be used efficiently without wastage of time.\n",
    "\n",
    "RTOS are controlling traffic signal; Nuclear reactors Control scientific experiments, medical imaging systems, industrial system, fuel injection system, home appliance are some application of Real Time operating system\n",
    "\n",
    "### Distributed Operating System(分布式)\n",
    "\n",
    "* In this Operating system Data is Stored and Processed on Multiple Locations.\n",
    "\n",
    "Distributed Operating System is a model where distributed applications are running on multiple computers linked by communications. A distributed operating system is an extension of the network operating system that supports higher levels of communication and integration of the machines on the network.\n",
    "\n",
    "This system looks to its users like an ordinary centralized operating system but runs on multiple, independent central processing units (CPUs).\n",
    "\n",
    "![Distributed Operating System](./img/linux/ATypical-View-of-Distributed-System.jpg)\n",
    "\n",
    "These systems are referred as loosely coupled systems where each processor has its own local memory and processors communicate with one another through various communication lines, such as high speed buses or telephone lines. By loosely coupled systems, we mean that such computers possess no hardware connections at the CPU – memory bus level, but are connected by external interfaces that run under the control of software.\n",
    "\n",
    "### Parallel systems(并行操作系统)\n",
    "Parallel systems:  As CPUs became less expensive and smaller, it became feasible to run a single program on several CPUs at once. Parallel computing is the discipline of building the hardware architectures, operating systems, and specialized algorithms for running a program on a cluster of processors. The multi-core technology now found in all new PCs can be used to run a single program or multiple programs on several processors simultaneously.\n",
    "\n",
    "### Multitasking（多任务）\n",
    "\n",
    "Multitasking term used in a **modern** computer system.\n",
    " \n",
    "Multitasking is a logical extension of multiprogramming system that supports multiple programs to run **concurrently.** \n",
    "\n",
    "\n",
    "* In **multitasking `more than one` task are executed at the `same` time**. \n",
    "\n",
    "For example, a browser, Word application, PowerPoint application, calculator application all can run at the same time. \n",
    " \n",
    "![multitasking](./img/linux/Multitasking.jpg)\n",
    "\n",
    "In this technique the multiple tasks, also known as **processes**(Multi-Process), share common processing resources such as a CPU.\n",
    "\n",
    "In the case of a computer with single CPU, only one job can be processed at a time. Multitasking solves the problem by scheduling and deciding which task should be the running task and when a waiting task should get turn. \n",
    "\n",
    "This attempt is done with the help of interrupt (a signal) which is attended by CPU by keeping the current activity aside, saves its present status in buffer and returns to another important job whatever task it was doing earlier. \n",
    "\n",
    "The act of re-assigning a CPU from one task to another one is known as context switch.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "### Multi-User(多用户）\n",
    "\n",
    "A Multi-user operating system is a computer operating system which allows multiple users to access the single system with one operating system on it. It is generally used on large mainframe computers.\n",
    "\n",
    "* Example: Linux, Unix, Windows 2000, Ubuntu, Mac OS etc.,\n",
    "\n",
    "In the multi-user operating system, different users connected at different terminals and we can access, these users through the network as shown in the diagram.\n",
    "\n",
    "**Features of the Multi-user Operating System**\n",
    "\n",
    "*  Multi-tasking: Using multi-user operating system we can perform multiple tasks at a time, i.e. we can run more than one program at a time.\n",
    "Example: we can edit a word document while browsing the internet.\n",
    "\n",
    "* Resource sharing: we can share different peripherals like printers, hard drives or we can share a file or data. For this, each user is given a small time slice of CPU time.\n",
    "\n",
    "* Background processing: It means that when commands are not processed firstly, then they are executed in the background while another programs are interacting with the system in the real time\n",
    "\n",
    "![Multi-user](./img/linux/multi-user-operating-system.jpg)\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Mutitasking and multi-user operating system"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "* Multitasking is the `concurrent` execution of `multiple` tasks (also known as processes) over a certain period of time. \n",
    "\n",
    "* Multi-user operating system is an operating system that allows `multiple users` to connect and operate a `single` operating system. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "多用户与多任务操作系统：是指一台计算机可以同时有多个用户同时使用，并且同时可以执行由多个用户提交的多个任务"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.7"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": false,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {
    "height": "calc(100% - 180px)",
    "left": "10px",
    "top": "150px",
    "width": "304.475px"
   },
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
